package ch.ffhs.links_library.session;

import ch.ffhs.links_library.entities.*;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.framework.EntityQuery;
import java.util.Arrays;

@Name("linkList")
public class LinkList extends EntityQuery<Link> {

	private static final long serialVersionUID = 4178322825973145819L;

	private static final String EJBQL = "select l from Link l";

	private static final String[] RESTRICTIONS = {
			"lower(link.destination) like lower(concat(#{linkList.link.destination},'%'))",
			"lower(link.name) like lower(concat(#{linkList.link.name},'%'))", };

	private Link link = new Link();

	public LinkList() {
		setEjbql(EJBQL);
		setRestrictionExpressionStrings(Arrays.asList(RESTRICTIONS));
		setMaxResults(25);
	}

	public Link getLink() {
		return link;
	}
}
